package com.keshan.service.impl;

import com.keshan.mapper.StepCountMapper;
import com.keshan.pojo.StepCount;
import com.keshan.pojo.StepCountEveryday;
import com.keshan.pojo.StepCountExample;
import com.keshan.utils.DateUtil;
import com.keshan.pojo.StepCountHide;
import com.keshan.service.StepCountServices;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @author keshan
 * @date 2022/10/21 - 19:46
 */
@Service
public class StepCountServicesImpl implements StepCountServices {
    @Autowired
    StepCountMapper stepCountMapper;
    @Override
    public int insertBySelectiveStepCount(StepCount stepCount) {
        return stepCountMapper.insertSelective(stepCount);
    }

//    @Override
//    public List<StepCount> getStepCountListByImeiToday(String imei) {
//        StepCountExample stepCountExample = new StepCountExample();
//        StepCountExample.Criteria criteria = stepCountExample.createCriteria();
//        criteria.andImeiEqualTo(imei);
//        List<Date> dateList = DateUtil.getStartAndEndToday();
//        criteria.andTimeBeginBetween(dateList.get(0),dateList.get(1));
//        List<StepCount> stepCountList = stepCountMapper.selectByExample(stepCountExample);
//        return stepCountList;
//    }
//
//    @Override
//    public List<StepCountHide> getStepCountListHideByImei(String imei) {
//        StepCountExample stepCountExample = new StepCountExample();
//        StepCountExample.Criteria criteria = stepCountExample.createCriteria();
//        criteria.andImeiEqualTo(imei);
//        return stepCountMapper.selectHideByExample(stepCountExample);
//    }

    @Override
    public List<StepCountHide> getStepCountListHideByUsernameToday(String username) {
        StepCountExample stepCountExample = new StepCountExample();
        StepCountExample.Criteria criteria = stepCountExample.createCriteria();
        criteria.andUsernameEqualTo(username);
        List<Date> dateList = DateUtil.getStartAndEndToday();
        criteria.andTimeBeginBetween(dateList.get(0),dateList.get(1));
        return stepCountMapper.selectHideByExample(stepCountExample);
    }

    @Override
    public List<StepCountEveryday> getStepCountEverydayListEveryday(String imei) {
        List<Date> dateList = DateUtil.getStartAndEndTwoMonth();
        return stepCountMapper.selectStepCountEveryday(dateList.get(0),dateList.get(1),imei);

    }
}
